package 代码记录.指定公司代码练习记录.华为_2024.华为od_2024笔试真题;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zx
 * @create 2024-02-28 20:23
 * 灰度图回复 - 100%
 */
public class Test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int z = sc.nextInt();
        int x = sc.nextInt();
        int res = binarySearch(arr, z, x);
        System.out.println(res);
    }
    private static int binarySearch(int[] arr, int z, int x){
        int target = (z * arr[1]) + x + 1;
        int left = 0, right = arr.length - 1;
        int res = 0;
        while (left < right){
            int mid = ((left + right) >> 1);
            int curSum = 0;
            for(int i = 3;i <= mid;){
                curSum += arr[i];
                i = i + 2;
            }
            if(curSum < target){
                left = mid + 1;
            }else if(curSum > target){
                right = mid;
            }else if(curSum == target){
                right = mid;
            }
        }
        res = arr[left - 1];
        return res;
    }
}
